{ Google Code Jam 2011. Round 2.
  Problemset: http://code.google.com/codejam/contest/dashboard?c=1150486
  Problem A.
  Verdict: Correct/Correct
}
uses SysUtils, Math;

type
	ar = array[1..3] of double;

var 
	i,tt,tests,x,s,r,n,cc:longint;
	b,e,w:array[0..1010] of longint;
	a:array[0..100010] of ar;
	ans,xx,t:double;

procedure sort(l,r:longint);
var
	i,j:longint;
	x:double;
	y:ar;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2][3];
repeat
	while a[i][3]<x do inc(i);
	while a[j][3]>x do dec(j);
	if i<=j then begin
		y:=a[i];
		a[i]:=a[j];
		a[j]:=y;
		inc(i);
		dec(j);
	end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
	
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(tests);
for tt:=1 to tests do begin
	fillchar(b,sizeof(b),0);
	fillchar(e,sizeof(e),0);
	fillchar(w,sizeof(w),0);
	fillchar(a,sizeof(a),0);
	write('Case #',tt,': ');
	read(x,s,r,t,n);
	ans:=0;
	cc:=0;
	for i:=1 to n do begin
		read(b[i],e[i],w[i]);
		if b[i]>e[i-1] then begin
			inc(cc);
			a[cc][1]:=b[i]-e[i-1];
			a[cc][2]:=a[cc][1]/s;
			a[cc][3]:=s;
		end;
		inc(cc);
		a[cc][1]:=e[i]-b[i];
		a[cc][2]:=a[cc][1]/(s+w[i]);
		a[cc][3]:=s+w[i];
	end;
	i:=n+1;
	b[i]:=x;
	e[i]:=x;
	w[i]:=0;
	if b[i]>e[i-1] then begin
		inc(cc); 
		a[cc][1]:=b[i]-e[i-1];
		a[cc][2]:=a[cc][1]/s; 
		a[cc][3]:=s;
	end;
	sort(1,cc);
	i:=1;
	while (t>0) and (i<=cc) do begin
		xx:=min(t*(a[i][3]-s+r),a[i][1]);
		a[i][2]:=(xx/(a[i][3]-s+r))+((a[i][1]-xx)/a[i][3]);
		t:=t-(xx/(a[i][3]-s+r));	 
		inc(i);
	end;
	for i:=1 to cc do 
		ans:=ans+a[i][2];
	writeln(ans:0:6);
end;
end.